package help

import "golang.org/x/crypto/bcrypt"

const PWDCOST int = 12

func GeneratePassword(pwd string) (string, error) {
	hash, err := bcrypt.GenerateFromPassword([]byte(pwd), PWDCOST)
	return string(hash), err
}

func CheckPassword(db_pwd string, pwd string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(db_pwd), []byte(pwd))
	if err != nil {
		return false
	}
	return true
}
